<?php
//require_once 'FModel/Framework/ICache.php';
abstract class CacheFactory {
	protected $config = array();
	protected $cache = null;
	
	protected function __construct() {
		$this->loadCacheConfig();
	}
	
	/**
	 * @return CacheFactory
	 */
	public static function getInstance() {
		return null;
	}
	
	public function __clone() {
		throw new Exception('clone is forbidden');
	}
	
	/**
	 * @return ICache
	 */
	public function getCache() {
		if (!$this->cache) {
			$this->cache = new Memcache();
			foreach ($this->config as $cfg) {
				$this->cache->addServer($cfg['host'], $cfg['port']);
			}
		}
		return $this->cache;
	}
	
	/**
	 * @return boolean
	 */
	public function isEnable() {
		return !empty($this->config);
	}
	
	abstract protected function loadCacheConfig();

}